package wash

/**
 *@ClassName WashMachine
 *
 *@Author ykx
 *@Date  2024/6/18 12:27
 *@Version 1.0
 */
class WashMachine(var module: String, var size: Int) {
    var isDoorOpen = true
    var current_mode = 0
    fun openDoor() {
        println("洗衣机打开门")
        isDoorOpen = true
    }

    fun closeDoor() {
        println("洗衣机门关闭了")
        isDoorOpen = false
    }

    fun selectMode(mode: Int) {
        current_mode = mode
        when (mode) {
            0 -> println("初始模式，请您选择模式")
            1 -> println("轻柔")
            2 -> println("狂揉")
            else -> println("不要乱拧，拧坏了不保修啊")
        }
    }

    fun start() {
        if (isDoorOpen) {
            println("哔哔…… 错误：洗衣机门没关")
        } else {
            when (current_mode) {
                0 -> {
                    println("选择模式错误，不能开始洗衣服")
                }
                1 -> {
                    println("放水")
                    println("轻柔开始，发动机转速 慢")
                    setMotorSpeed(100)
                    println("洗完了")
                }
                2 -> {
                    println("放水")
                    println("狂柔开始，发动机转速 快")
                    setMotorSpeed(200)
                    println("洗完了")
                }
                else -> {
                    println("选择模式错误，不能开始洗衣服")
                }
            }
        }
    }

    private fun setMotorSpeed(speed: Int) {
        println("当前发动机转速为${speed}圈/秒")
    }

}